<!-- Framebuffer object の作成テスト（console出力のみ） -->
<html> 
<head> 
<script>
  function start()
  {
    var canvas = document.getElementById("myCanvas");
    
    var gl = canvas.getContext("experimental-webgl");
    if (!gl) {
      alert("Failed to create WebGL context.");
      return null;
    }
    
    var width = 400;
    var height = 400;
    
    // Framebuffer objectの作成
    var framebuffer  = gl.createFramebuffer();
    gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
    framebuffer.width = width;
    framebuffer.height = height;
    
    // 割り当てるテクスチャを作成
    var texture = gl.createTexture();
    {
      gl.bindTexture(gl.TEXTURE_2D, texture);
      gl.activeTexture(gl.TEXTURE0);
      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
      gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
      
      // テクスチャをFramebuffer objectのカラーアタッチメントに設定
      gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
      
      gl.bindTexture(gl.TEXTURE_2D, null);
    }
    
    // 
    if (!gl.isFramebuffer(framebuffer)) {
      alert("Failed to create framebuffer object");
    } else {
      console.log("Success to create framebuffer object.");
    }
    
    var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
    if (status != gl.FRAMEBUFFER_COMPLETE) {
      console.log("status != gl.FRAMEBUFFER_COMPLETE");
    } else {
      console.log("status == gl.FRAMEBUFFER_COMPLETE");
    }
  }
</script> 
</head> 
 
<body onload="start()"> 
<canvas id="myCanvas"> </canvas> 
</body> 
</html> 
